package com.zhang.paymentdemo.controller;

import com.google.gson.Gson;
import com.zhang.paymentdemo.config.WxPayConfig;
import com.zhang.paymentdemo.vo.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @ClassName TestController
 * @Description 测试
 * @Author zhanghongguo
 * @Date 2022/1/8 14:56
 * @Version 1.0
 */
@Api(tags = "测试")
@RestController
@RequestMapping("api/test")
public class TestController {
    @Autowired
    private WxPayConfig wxPayConfig;

    @RequestMapping(value = "test1",method = RequestMethod.GET)
    public R test1(){
        return R.ok().data("appid",wxPayConfig.getAppid());
    }
    @RequestMapping(value = "test2",method = RequestMethod.GET)
    public R test2(){
        return R.ok().setCode(111).setMessage("hhh");
    }
    @RequestMapping(value = "test3",method = RequestMethod.GET)
    public R test3(){
        Gson gson = new Gson();
        HashMap<String, Object> map = new HashMap<>();
        map.put("name","张三");
        map.put("age","18");
        map.put("sex","男");
        String str = gson.toJson(map);
        return R.ok().data("json",str);
    }

}
